package com.whalehearing.tingyou.common.utils;


import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.NoArgsConstructor;

/**
 * @author zengjun-qxm
 */ //统一响应结果
@NoArgsConstructor  //无参构造
@AllArgsConstructor //全参构造
@Data               //必须加：否则没有setget方法，会报：No acceptable representation
public class ResultZengJun<T> {
    //业务状态码  200-成功  201-失败
    private Integer code;
    //提示信息
    private String msg;
    //响应数据
    private T data;

    //快速返回操作成功响应结果(带响应数据)
    public static <E> ResultZengJun<E> success(E data) {
        return new ResultZengJun<>(200, "操作成功", data);
    }

    //快速返回操作成功响应结果
    public static ResultZengJun success() {
        return new ResultZengJun(200, "操作成功", null);
    }

    public static ResultZengJun success(Object data,String msg) {
        return new ResultZengJun(200, msg, data);
    }

    public static ResultZengJun error(String msg) {
        return new ResultZengJun(201, msg, null);
    }
}
